VERSION 5.00
Object = "{FE0065C0-1B7B-11CF-9D53-00AA003C9CB6}#1.1#0"; "COMCT232.OCX"
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form frmCABCompress 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Compressing Data..."
   ClientHeight    =   4695
   ClientLeft      =   4395
   ClientTop       =   1695
   ClientWidth     =   5070
   Icon            =   "CABCompress.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4695
   ScaleWidth      =   5070
   Begin VB.Frame fraFile 
      Caption         =   "File"
      Height          =   1575
      Left            =   120
      TabIndex        =   6
      Top             =   2520
      Width           =   4815
      Begin ComctlLib.ProgressBar barByteCount 
         Height          =   255
         Left            =   120
         TabIndex        =   11
         Top             =   1200
         Width           =   4575
         _ExtentX        =   8070
         _ExtentY        =   450
         _Version        =   327682
         Appearance      =   0
      End
      Begin VB.Label lblFileStatus 
         Alignment       =   2  'Center
         Height          =   255
         Left            =   120
         TabIndex        =   9
         Top             =   240
         Width           =   4575
      End
      Begin VB.Label lblFileName 
         Alignment       =   2  'Center
         Height          =   375
         Left            =   120
         TabIndex        =   8
         Top             =   480
         Width           =   4575
         WordWrap        =   -1  'True
      End
      Begin VB.Label lblByteCount 
         Alignment       =   2  'Center
         Height          =   255
         Left            =   120
         TabIndex        =   7
         Top             =   840
         Width           =   4575
      End
   End
   Begin VB.Frame fraCabinet 
      Caption         =   "Cabinet"
      Height          =   1575
      Left            =   120
      TabIndex        =   2
      Top             =   840
      Width           =   4815
      Begin ComctlLib.ProgressBar barCABCompress 
         Height          =   255
         Left            =   120
         TabIndex        =   10
         Top             =   1200
         Width           =   4575
         _ExtentX        =   8070
         _ExtentY        =   450
         _Version        =   327682
         Appearance      =   0
      End
      Begin VB.Label lblCABStatus 
         Alignment       =   2  'Center
         Height          =   255
         Left            =   120
         TabIndex        =   5
         Top             =   240
         Width           =   4575
      End
      Begin VB.Label lblCABName 
         Alignment       =   2  'Center
         Height          =   375
         Left            =   120
         TabIndex        =   4
         Top             =   480
         Width           =   4575
         WordWrap        =   -1  'True
      End
      Begin VB.Label lblCABFileCount 
         Alignment       =   2  'Center
         Height          =   255
         Left            =   120
         TabIndex        =   3
         Top             =   840
         Width           =   4575
      End
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "&Cancel"
      Height          =   375
      Left            =   1920
      TabIndex        =   1
      Top             =   4200
      Width           =   1215
   End
   Begin ComCtl2.Animation aniCABCompress 
      Height          =   615
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   4815
      _ExtentX        =   8493
      _ExtentY        =   1085
      _Version        =   327681
      AutoPlay        =   -1  'True
      Center          =   -1  'True
      FullWidth       =   321
      FullHeight      =   41
   End
End
Attribute VB_Name = "frmCABCompress"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'*---------------------------------------------------------------
'*
'* FormName:       frmCABCompress
'* FileName:       CABCOMPRESS.FRM
'* Date:           July 1998
'* Author:         Ian M. Weatherburn
'* Company:        Mindkey Software Solutions (Pty) Ltd.
'* Copyright:      Copyright (C) 1998 by Mindkey Software Solutions
'*                 All Rights Reserved
'* Description:    Compress files from the File List collection
'*                 into a Microsoft .CAB file for uploading
'*                 Provide the user with constant feedback
'*                 via progress meters, and text descriptions
'*                 of what is happening
'*---------------------------------------------------------------

Option Explicit

Private WithEvents objCABCompress As clsCreateCab
Attribute objCABCompress.VB_VarHelpID = -1
Private strTransferFile As String
Private blnCancel As Boolean
Private intTotalFiles As Integer
Private blnUnloading As Boolean

Private lngByteCount As Long
Private lngFileSize As Long
Private strCurrentFile As String

Private Sub cmdCancel_Click()
  blnCancel = True
  Unload Me
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  If blnUnloading = True Then
    Cancel = False
  Else
    blnUnloading = True
    If blnCancel = False Then
      Cancel = False
    Else
      If MsgBox("Are you sure you want to Cancel the Compression?", _
                vbYesNo Or vbQuestion, _
                "Cancel Compression") = vbYes Then
        LogEvent "User cancelled upload file CAB compression"
        Cancel = False
      Else
        Cancel = True
        blnUnloading = False
        blnCancel = False
      End If
    End If
  End If
End Sub

Private Sub objCABCompress_BeforeFileAdd(intFileCount As Integer, _
                                         strFileName As String, _
                                         blnCancelCreate As Boolean)
                                         
  blnCancelCreate = blnCancel
  
  If Not blnCancel Then
  
    lngByteCount = 0
    lngFileSize = objFileList.Length(intFileCount)
    strCurrentFile = strFileName
  
    UpdateCABStatus "Adding Files to Cabinet...", intFileCount, intTotalFiles
  End If
                                         
End Sub

Private Sub objCABCompress_CompressStatus(StatusType As FDINT, _
                                          StatusInfo1 As Long, _
                                          StatusInfo2 As Long, _
                                          blnCancelCompress As Boolean)

  blnCancelCompress = blnCancel
  
  If Not blnCancel Then
    Select Case StatusType
      Case fdintCABINET_INFO
        lngByteCount = lngByteCount + StatusInfo1
        UpdateFileStatus "Compressing File...", _
                         strCurrentFile, _
                         lngByteCount, _
                         lngFileSize
      Case fdintPARTIAL_FILE
        lngByteCount = lngFileSize
        UpdateFileStatus "Compressing File...", _
                         strCurrentFile, _
                         lngByteCount, _
                         lngFileSize
    End Select
  End If

End Sub

Private Sub Form_Activate()

  ' Set the mouse pointer
  MousePointer = vbArrowHourglass

  ' Get Animation going as soon as possible
  aniCABCompress.Open App.Path & "\FILECOPY.AVI"
  
  ' Make sure we don't CANCEL right off
  blnCancel = False

  ' Create CAB Compress object
  Set objCABCompress = New clsCreateCab
  
  ' Get the .CAB filename, create the file and update the display
  strTransferFile = GetCABFileName
  lblCABName = strTransferFile
  
  UpdateCABStatus "Creating Cabinet..."
  objCABCompress.CabinetFile = strTransferFile
  
  ' Add the list of files to the .CAB
  Dim intLoop As Integer
  Dim strCompressFile As String
  
  intTotalFiles = objFileList.Count
  For intLoop = 1 To intTotalFiles
  
    ' Get the name of the chosen file
    strCompressFile = objFileList.Item(intLoop)
    
    ' Compress the file into the .CAB
    objCABCompress.ToCompressFiles.AddFile strCompressFile
  Next intLoop
    
  UpdateCABStatus "Writing out Cabinet..."
  objCABCompress.Compress
  
  DoEvents
 
  UpdateCABStatus "Cabinet Compression Complete."
 
  Unload Me

End Sub

Private Sub UpdateCABStatus(ByVal strStatus As String, _
                            Optional ByVal intFileNo As Long = 0, _
                            Optional ByVal intTotalFiles As Long = 0)
                         
  lblCABStatus.Caption = strStatus
  
  If intFileNo = 0 Or intTotalFiles = 0 Then
    lblCABFileCount.Visible = False
    barCABCompress.Visible = False
  Else
    lblCABFileCount.Visible = True
    barCABCompress.Visible = True
    lblCABFileCount.Caption = "File " & _
                              CStr(intFileNo) & _
                              " of " & _
                              CStr(intTotalFiles)
                           
    barCABCompress.Value = CInt((intFileNo / intTotalFiles) * 100)
  End If
                         
  Refresh
  DoEvents
  
End Sub

Private Sub UpdateFileStatus(ByVal strStatus As String, _
                             ByVal strFileName As String, _
                             ByVal lngByteCount As Long, _
                             ByVal lngTotalSize As Long)
                                   
  lblFileStatus.Caption = strStatus
  lblFileName.Caption = strFileName
  
  lblByteCount.Caption = Format(lngByteCount, "###,###,###,###,##0") & _
                         " bytes of " & _
                         Format(lngTotalSize, "###,###,###,###,##0")
  
  If lngByteCount > lngTotalSize Then
    barByteCount.Value = barByteCount.Max
  Else
    barByteCount.Value = CInt((lngByteCount / lngTotalSize) * 100)
  End If
  
  Refresh
  DoEvents
                                   
End Sub

Private Function GetCABFileName()

  GetCABFileName = objCABFile.CabFileName

End Function

Private Sub Form_Unload(Cancel As Integer)

  ' Reset the mouse pointer
  MousePointer = vbDefault

  ' Stop the animation
  aniCABCompress.AutoPlay = False
  aniCABCompress.Stop
  aniCABCompress.Close
  
End Sub
